package multiThreading;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class C {
    public static void main(String arg[]){
        ScheduledExecutorService pool=Executors.newScheduledThreadPool(3);//建立一个可定时调度的线程池
        pool.schedule(new Runnable() {
            @Override
            public void run(){
                System.out.println("延迟一秒开始");
            }

        },1, TimeUnit.SECONDS);//代表意思为延迟三秒执行
        pool.shutdown();
//        pool.scheduleAtFixedRate(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("延迟一秒开始，每3秒执行一次");
//            }
//        },1,3,TimeUnit.SECONDS);

    }
}
class c1 extends Thread{
    @Override
    public void run() {
        for(int i=0;i<100;i++){
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}